<?php 
## include required files
/*******************************/
require_once '../model/nab.php';
require_once '../model/moduleuser.php';
## Paginaton class
require_once ("../includes/classes/pagination_class.php");
/*******************************/

## Create Objects
/*******************************/
$nabObj   = new Model_NAB();
$moduleObj = new Model_ModuleUser();
/*******************************/
if($_GET['q']=='nab')
{
	$moduelArray=$moduleObj->getModuleHelpText(14);
	$smarty->assign('moduelArray', $moduelArray);
	//echo '<pre>';print_r($moduelArray);exit;
}

## Getting all details from the database 
$res = $nabObj->getDetailsFromNAB();

if($res[0]['mode'])
	$res[0]['mode'] = 'Live';
else
	$res[0]['mode'] = 'Test';
//echo "<pre>";print_r($res);exit;
$smarty->assign('NabArray', $res);
/*##Fetch all place pages from database
if($_POST['search']) {
	$search = $_POST['search'];
}
if($_GET["search"]){
	$search = $_GET['search'];
}
$search = addslashes(trim($search));
$smarty->assign("search",$search);

##  --------- Pagination part first start --------------##
	if( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] != "" ) {
		$pageNum = $_GET[ 'page' ];
	} else {
		$pageNum = 1;
	} 
	$rowsPerPage = ROW_PER_PAGE;
	$pageName = "home.php?q=places"; 
	## Count all the records
	$placeArray = $roonObj->getAllPlacesByAllUsers($search,0,0,false);
	$total_rows = count($placeArray);
	$offset	= ($pageNum - 1) * $rowsPerPage;
	$smarty->assign('page', $pageNum);
##  --------- Pagination part first end --------------##


##  --------- Pagination part second start --------------##
	$newid = $pageNum * $rowsPerPage - $rowsPerPage + 1;
	$smarty->assign('newid', $newid);
	$placeArray = $roonObj->getAllPlacesByAllUsers($search,$rowsPerPage,$offset,true);
//	echo "<pre>"; print_r($placeArray);exit;
	$smarty->assign('placeArray', $placeArray);
	if($total_rows > ROW_PER_PAGE) {
		$pg = new pagination();					// CREATING OBJECT OF THE PAGINATION CLASS
		$pgnation = $pg->pagination_admin( $total_rows , $rowsPerPage , $pageNum , $pageName , $other_id, $class);	
		$smarty-> assign("pagination",$pgnation);
	}
##  --------- Pagination part second end --------------##	
*/
## Assign session message to smarty variable and unset session variable
if($_SESSION['msg'] != '') {
	$smarty->assign('msg', $_SESSION['msg']);	
	unset($_SESSION['msg']);
}

## Set active class variable for left menu (main menu and sub menu)
$smarty->assign('activeclass', 'nab');
$smarty->assign('mainmenu', '5');

## Unset all the objects created which are on this page
unset($nabObj);
unset($moduleObj);

$smarty->display(TEMPLATEDIR_ADMIN. 'nab/nab.tpl');
unset($smarty);
?>